package com.jwds.digital.bios.business.api.controller.belt;

import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltExceptionDict;
import com.jwds.digital.bios.business.service.service.belt.IBeltHealthConfigService;
import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltHealthConfigReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltHealthConfigRespVO;
import com.jwds.tdc.framework.application.lib.BaseResponse;
import com.jwds.tdc.framework.application.lib.page.PageRequest;
import com.jwds.tdc.framework.application.lib.page.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 皮带健康配置表 前端控制器
 *
 * @author 林柏云
 * @date 2024-10-24
 */
@Slf4j
@Api(tags = "皮带健康配置表")
@RestController
@RequestMapping("/belt/health/config")
public class BeltHealthConfigController {

  @Resource
  private IBeltHealthConfigService service;


  @GetMapping("/all")
  @ApiOperation(value = "查询全部数据")
  public BaseResponse<List<BeltHealthConfigRespVO>> list() {
    List<BeltHealthConfigRespVO> respVoList = service.findAll();
    return BaseResponse.success(respVoList);
  }


  @PostMapping("/add")
  @ApiOperation(value = "新增")
  public BaseResponse<?> add(@Validated @RequestBody BeltHealthConfigReqDTO reqDto) {
    service.add(reqDto);
    return BaseResponse.success();
  }



  @PutMapping("/update")
  @ApiOperation(value = "更新对象")
  public BaseResponse<?> update(@Validated @RequestBody BeltHealthConfigReqDTO reqDto) {
    service.update(reqDto);
    return BaseResponse.success();
  }

  @PatchMapping("/enable/{id}")
  @ApiOperation(value = "启用")
  public BaseResponse<?> enable(@PathVariable("id") Long id) {
    service.enable(id);
    return BaseResponse.success();
  }

  @PatchMapping("/disable/{id}")
  @ApiOperation(value = "禁用")
  public BaseResponse<?> disable(@PathVariable("id") Long id) {
    service.disable(id);
    return BaseResponse.success();
  }

//  @DeleteMapping("/{id}")
//  @ApiOperation(value = "删除")
//  public BaseResponse<?> delete(@PathVariable("id") Long id) {
//    service.delete(id);
//    return BaseResponse.success();
//  }


  @GetMapping("/allDict")
  @ApiOperation(value = "查询皮带扣分项数据")
  public BaseResponse<List<BeltExceptionDict>> findDictAll() {
    List<BeltExceptionDict> respVoList = service.findDictAll();
    return BaseResponse.success(respVoList);
  }

  //分页
  @PostMapping("/page")
  @ApiOperation(value = "分页查询")
  public BaseResponse<PageResponse<BeltHealthConfigRespVO>> page(@RequestBody PageRequest<BeltHealthConfigReqDTO> pageReq){
    PageResponse<BeltHealthConfigRespVO> respVoPage = service.page(pageReq);
    return BaseResponse.success(respVoPage);
  }

}
